package psi

import (
	"fmt"
	"strings"
)

/*
开关机时间设置
平台发送：
[DW*YYYYYYYYYYYYYYY*LEN*BOOTOFF,开关（0 关，1 开），开机时间，关机时间]
例:[DW*334588000000156*LEN* BOOTOFF,1，07:10，21：00]
终端回复:
[DW*YYYYYYYYYYYYYYY*LEN*BOOTOFF]
实例:[DW*334588000000156*LEN*BOOTOFF]
*/

// 开关机时间设置
type BOOTOFF struct {
	Switch int    // 开关（0 关，1 开）
	Open   string // 开机时间
	Close  string // 关机时间
}

func DealBOOTOFF(method string, params map[string]interface{}) (string, error) {
	var bootoff BOOTOFF
	err := MapToStruct(params, &bootoff)
	if err != nil {
		return "", err
	}
	var messageList []string
	messageList = append(messageList, "BOOTOFF")
	messageList = append(messageList, fmt.Sprint(bootoff.Switch))
	messageList = append(messageList, bootoff.Open)
	messageList = append(messageList, bootoff.Close)
	message := strings.Join(messageList, ",")
	return message, nil
}
